package com.ikas.ai.server.module.condition.service;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ikas.ai.server.module.condition.dao.WorkConditionStepDao;
import com.ikas.ai.server.module.condition.model.WorkConditionStep;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @Description: 工况步骤Service
 * @Author: qi.yilai
 * @Date: 2023/4/13 10:07
 * @Version: 1.0.0
 **/
@Service
public class WorkConditionStepService extends ServiceImpl<WorkConditionStepDao, WorkConditionStep> {

    /**
     * 获取某个工况的所有步骤列表
     *
     * @param wfId
     * @return
     */
    public List<WorkConditionStep> getWorkConditionStepByWfId(Long wfId) {
        LambdaQueryChainWrapper<WorkConditionStep> lambdaQueryChainWrapper = lambdaQuery();
        return lambdaQueryChainWrapper.eq(WorkConditionStep::getWfId, wfId).orderByAsc(WorkConditionStep::getSort).list();
    }

    /**
     * 删除某个工况步骤记录
     *
     * @param wfId
     */
    public void removeWorkConditionStepByWfId(Long wfId) {
        LambdaQueryWrapper<WorkConditionStep> lambdaQueryWrapper = new LambdaQueryWrapper<>();
        lambdaQueryWrapper.eq(WorkConditionStep::getWfId, wfId);
        remove(lambdaQueryWrapper);
    }
}
